#include <bits/stdc++.h>
using namespace std;
int a, b, ans;
bool isPal() {
  int q = a / 10;
  int w = a % 10;
  int e = b / 10;
  int f = b % 10;
  return (q == f && w == e);
}
int main() {
  scanf("%d:%d", &a, &b);
  ans = 0;
  while (!isPal()) {
    ans++;
    b++;
    if (b >= 60) {
      b -= 60;
      a++;
      if (a >= 24) {
        a = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
