#include <bits/stdc++.h>
using namespace std;
int judge(int x, int y) {
  int a = x / 10;
  int b = x % 10;
  int c = y / 10;
  int d = y % 10;
  if (a == d && b == c)
    return 1;
  else
    return 0;
}
int main() {
  int a, b;
  scanf("%d:%d", &a, &b);
  int d;
  int x, y;
  int result;
  for (int i = 0; i < 1440; i++) {
    x = (a + (b + i) / 60) % 24;
    y = (b + i) % 60;
    d = judge(x, y);
    if (d == 1) {
      result = i;
      break;
    }
  }
  cout << result << endl;
  return 0;
}
